home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
midi
/
gfft.lha
/
gfft-2.03
/
source
/
gfft-2.03-source.lha
/
oktime3d.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-02
|
4KB
|
119 lines
/***************************************************************************
* Copyright (C) 1994 Charles P. Peterson *
* 4007 Enchanted Sun, San Antonio, Texas 78244-1254 *
* Email: Charles_P_Peterson@fcircus.sat.tx.us *
* *
* This is free software with NO WARRANTY. *
* See gfft.c, or run program itself, for details. *
* Support is available for a fee. *
***************************************************************************
*
* Program: gfft--General FFT analysis
* File: oktime3d.c
* Purpose: do a time-3D spectrum (meaning amplitude vs. freq. vs. time)
* Author: Charles Peterson (CPP)
* History: 10-February-1994 CPP; Created.
* 29-August-1994 CPP (1.12); offset start time by 1/2
* interval to permit logarithmic displays.
* 7-Feb-95 CPP (1.31); Progress Requester
*
* Comment: To preserve the full set of options available in a regular
* ('flat') FFT, this function simply sets up and calls
* ok_spectrum for each 'time segment.'
* It 'forces' each segment by setting StartFrame and Frames
* as required. Their original values are preserved
* here.
* The real StartFrame (as specified by user) and Frames
* are to refer to the dataset as a whole,
* and NOT to each Time Segment. Most other options
* (Overlap, Pad, Interleave, etc.) may still be applied
* to each individual time segment.
*/
#include "gfft.h"
#include "settings.h" /* Power, Amplitude, ReadPtr */
long Actual_Time_Segments = 1; /* Used by progress indicator */
extern long Inner_Loop_Count;
ULONG ok_time3d_spectrum (BOOLEAN do_it_for_real)
{
ULONG save_ok_start_frame = OkStartFrame;
ULONG save_ok_frames = OkFrames;
ULONG dummy = 0;
ULONG frames;
ULONG running_offset;
ULONG bins_used = 0;
double segment_time_increment;
double fudge = 1.0 / LONG_MAX; /* compensate for floating inaccuracy */
double time_overlap = TimeOverlap;
long time_seg_size = TimeSegSize;
long time_offset = TimeOffset;
long i;
Actual_Time_Segments = TimeSegments;
if (time_overlap == INVALID_SET ||
time_offset == INVALID_SET ||
Actual_Time_Segments == INVALID_SET ||
time_seg_size == INVALID_SET)
{
error_message (INVALID_TIMESEG_PARAMETERS);
RAISE_ERROR (NOTHING_SPECIAL); /* longjmp outa here! */
}
frames = (OkFrames != ULONG_MAX) ? OkFrames :
ok_read (NULL, dummy);
if (time_seg_size == NOT_SET)
{
if (Actual_Time_Segments == NOT_SET)
{
error_message (MISSING_TIMESEG_PARAMETERS);
RAISE_ERROR (NOTHING_SPECIAL); /* longjmp outa here! */
}
if (time_offset == NOT_SET)
{
time_seg_size = fudge + (frames /
(1.0 + (1.0 - time_overlap) * (Actual_Time_Segments - 1)));
time_offset = fudge + (time_seg_size * (1.0 - time_overlap));
}
else
{
time_seg_size = frames - (time_offset * (Actual_Time_Segments - 1));
}
}
else
{
if (time_offset = NOT_SET)
{
time_offset = fudge + (time_seg_size * (1.0 - time_overlap));
}
Actual_Time_Segments = ((frames - time_seg_size) / time_offset) + 1;
}
/*
* Now, we have the all dependent and independent parameters
*/
segment_time_increment = time_seg_size / OkRate;
OkSegmentTime = segment_time_increment / 2;
Inner_Loop_Count = 0;
running_offset = save_ok_start_frame;
for (i = 0; i < Actual_Time_Segments; i++)
{
OkStartFrame = running_offset;
OkFrames = time_seg_size;
ok_rewind ();
bins_used = ok_spectrum (do_it_for_real);
if (!do_it_for_real) return bins_used;
running_offset += time_offset;
OkSegmentTime += segment_time_increment;
}
OkStartFrame = save_ok_start_frame;
OkFrames = save_ok_frames;
Actual_Time_Segments = 1;
return bins_used;
}